<?xml version="1.0" encoding="utf-8" ?>

<Project DefaultTargets="DebugBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <PackageName>$(TargetName).wsp</PackageName>
    <TargetUrl>http://litwareinc.com</TargetUrl>
    <ProjectDeploymentFilesFolder>@DeploymentFilesFolder</ProjectDeploymentFilesFolder>
    <ProjectRootFilesFolder>@RootFilesFolder</ProjectRootFilesFolder>
    <WssRootFilesFolder>"$(ProgramFiles)\Common Files\Microsoft Shared\web server extensions\12"</WssRootFilesFolder>
    <MAKECAB>"$(WINDIR)\System32\makecab.exe"</MAKECAB>
    <STSADM>"$(ProgramFiles)\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe"</STSADM>
    <STSDEV>"$(StsDevPath)\stsdev.exe"</STSDEV>
    <SafeProjectDir>"$(ProjectDir)"</SafeProjectDir>
  </PropertyGroup>

<Target Name="DebugBuild">
  <Message Text="Refreshing Deployment Files..." Importance="high" />
  <Exec Command="$(STSDEV) /refresh $(TargetName) $(SafeProjectDir)" ContinueOnError="true" />
  <Message Text="Deleting Solution Package File..." Importance="high" />
  <Delete Files="$(ProjectDeploymentFilesFolder)\$(PackageName)" ContinueOnError="true" />
  <Message Text="Building Solution Package (Debug Version)" Importance="high" />
  <Exec Command="$(MAKECAB) /F $(ProjectDeploymentFilesFolder)\SolutionPackage.ddf /D CabinetNameTemplate=$(OutDir)\$(PackageName)" ContinueOnError="false" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugInstall" DependsOnTargets="DebugBuild">
  <Message Text="Installing Solution..." Importance="high" />
  <Exec Command="$(STSADM) -o addsolution -filename $(OutDir)\$(PackageName)" ContinueOnError="true" />
  <Exec Command="$(STSADM) -o execadmsvcjobs" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugDeploy" DependsOnTargets="DebugInstall">
  <Message Text="Deploying Solution..." Importance="high" />
  <Exec Command="$(STSADM) -o deploysolution -name $(PackageName) @StsAdmDeployParameters" />
  <Exec Command="$(STSADM) -o execadmsvcjobs" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugRedeploy" >
  <Message Text="" Importance="high" />
  <Message Text="Starting sequence of Retract/Delete/Build/Install/Deploy" Importance="high" />
  <CallTarget Targets="DebugRetract" />
  <CallTarget Targets="DebugDelete" />
  <CallTarget Targets="DebugBuild" />
  <CallTarget Targets="DebugInstall" />
  <CallTarget Targets="DebugDeploy" />
  <CallTarget Targets="DebugDeploy" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugUpgrade" DependsOnTargets="DebugBuild">
  <Message Text="Updating solution" Importance="high" />  
  <Exec Command="$(STSADM) -o upgradesolution -name $(PackageName) -filename $(OutDir)\$(PackageName) @StsAdmUpgradeParameters" />
  <Exec Command="$(STSADM) -o execadmsvcjobs" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugQuickCopy" >
  <Message Text="Copying Root Files to WSS system folder" />
  <Copy SourceFiles="$(ProjectRootFilesFolder)\*" DestinationFolder="$(WssRootFilesFolder)" SkipUnchangedFiles="true" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugRetract" >
  <Message Text="Retracting Solution" />
  <Exec Command="$(STSADM) -o retractsolution -name $(PackageName) @StsAdmRetractParameters" ContinueOnError="true" />
  <Exec Command="$(STSADM) -o execadmsvcjobs" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="DebugDelete" DependsOnTargets="DebugRetract">
  <Message Text="Deleting Solution Package from Farm Solution Package Store" />
  <Exec Command="$(STSADM) -o deletesolution -name $(PackageName)" ContinueOnError="true" />
  <Exec Command="$(STSADM) -o execadmsvcjobs" />
  <Message Text="" Importance="high" />
</Target>

<Target Name="ReleaseBuild" >
  <Message Text="Refreshing Deployment Files..." Importance="high" />
  <Exec Command="$(STSDEV) /refresh $(TargetName) $(SafeProjectDir) $(OutDir)" ContinueOnError="true" />
  <Message Text="Deleting Pacakge File..." Importance="high" />
  <Delete Files="$(ProjectDeploymentFilesFolder)\$(PackageName)" ContinueOnError="true" />
  <Message Text="Building Cab File (Release Version)" Importance="high" />
  <Exec Command="$(MAKECAB) /F $(ProjectDeploymentFilesFolder)\SolutionPackage.ddf /D CabinetNameTemplate=$(OutDir)\$(PackageName)" ContinueOnError="false" />
  <Message Text="" Importance="high" />
</Target>

</Project>